import request from '@/utils/request'

export interface AppInterface {
  id?: string
  createBy?: string | null
  updateBy?: string | null
  createTime?: string
  updateTime?: string
  delFlag?: string
  remarks?: string | null
  name: string | null
  userName: string
  backgroundUrl?: string | any
  enterAppBeforeLogin: number
}

export function getAppList (params: any) {
  return request({
    url: '/v1/system-application/searchPage',
    method: 'get',
    params
  })
}

export function addApp (data: AppInterface) {
  return request({
    url: '/v1/system-application/add',
    method: 'post',
    data
  })
}

export function appDetail (id: string) {
  return request({
    url: `/v1/system-application/getById`,
    method: 'get',
    params: {
      id
    }
  })
}

export function updateApp (data: any) {
  return request({
    url: `/v1/system-application/update`,
    method: 'POST',
    data
  })
}

export function deleteApp (id: string) {
  return request({
    url: `/v1/system-application/delete`,
    method: 'POST',
    data: {
      id
    }
  })
}

export function exportSql (appId: string) {
  return request({
    url: `/v1/system-application/generateSql`,
    method: 'POST',
    data: {
      appId
    }
  })
}
